<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8">
		<title>Class: Scroller - documentation</title>
  
		<style type="text/css" media="screen">
			@import "media/css/doc.css";
			@import "media/css/shCore.css";
			@import "media/css/shThemeDataTables.css";
		</style>
	
		<script type="text/javascript" src="media/js/shCore.js"></script>
		<script type="text/javascript" src="media/js/shBrushJScript.js"></script>
		<script type="text/javascript" src="media/js/jquery.js"></script>
		<script type="text/javascript" src="media/js/doc.js"></script>
	</head>
	<body>
		<div class="fw_container">
			
				<a name="top"></a>
				<div class="fw_header">
					<h1 class="page-title">Class: Scroller</h1>
					
					<div class="page-info">
						Scroller v1.0.0 documentation
					</div>
				</div>

				

				<div class="fw_nav">
					<h2>Navigation</h2>
					<ul>
					<li><a href="#top">Overview</a></li>
					<li><a href="#summary">Summary</a><div><a href="#summary_namespaces">Namespaces</a> | <a href="#summary_methods">Methods</a></div></li><li><a href="#details">Details</a><div><a href="#details_methods">Methods</a></div></li></ul>
					<div style="margin-top: 10px;">
						<input type="hidden" name="show_private" value="0">
						<span id="private_label">Hiding</span> private elements 
							(<a id="private_toggle" href="">toggle</a>)
						</span>
					</div>
					<div>
						<input type="hidden" name="show_extended" value="1">
						<span id="extended_label">Showing</span> extended elements 
							(<a id="extended_toggle" href="">toggle</a>)
						</span>
					</div>
				</div>

				<div class="fw_content">
					<a name="overview"></a>
					<div class="doc_overview">
						<div class="nav_blocker"></div>
						<dl><dt id="<anonymous>~Scroller" class=" even"><a name="Scroller_details"></a><span class="type-attr"></span><span class="type-name"><a>new Scroller</a></span><span class="type-sig"><span class="type-brace">(</span> oDT:<span class="type-param">object</span>, [oOpts:<span class="type-param">object</span>] <span class="type-brace">)</span></span></span></dt><dd class=" even"><p class="description">Scroller is a virtual rendering plug-in for DataTables which allows large
datasets to be drawn on screen every quickly. What the virtual rendering means
is that only the visible portion of the table (and a bit to either side to make
the scrolling smooth) is drawn, while the scrolling container gives the 
visual impression that the whole table is visible. This is done by making use
of the pagination abilities of DataTables and moving the table around in the
scrolling container DataTables adds to the page. The scrolling container is
forced to the height it would be for the full table display using an extra 
element. <br><br>Note that rows in the table MUST all be the same hight. Information in a cell
which expands on to multiple lines will cause some odd behaviour in the scrolling.<br><br>Scroller is initialised by simply including the letter 'S' in the sDom for the
table you want to have this feature enabled on. Note that the 'S' must come
AFTER the 't' parameter in sDom.<br><br>Key features include:
  <ul class="limit_length">
    <li>Speed! The aim of Scroller for DataTables is to make rendering large data sets fast</li>
    <li>Full compatibility with deferred rendering in DataTables 1.8 for maximum speed</li>
    <li>Correct visual scrolling implementation, similar to "infinite scrolling" in DataTable core</li>
    <li>Integration with state saving in DataTables (scrolling position is saved)</li>
    <li>Easy to use</li>
  </ul></p><h3>Constructor</h3><dl class="details">
	
	
	
	
	
	
	
	
	
	
	
	
	
</dl><h5>Parameters:</h5>

<table class="params">
    <thead>
	<tr>
        <th width="20"></th>
        <th width="12%" class="bottom_border name">Name</th>
		<th width="10%" class="bottom_border">Type</th>
		<th width="10%" class="bottom_border">Attributes</th>
		<th width="10%" class="bottom_border">Default</th>
		<th class="last bottom_border">Description</th>
	</tr>
	</thead>
	
	<tbody>
	<tr class="even"><td class="number right_border"><div>1</div></td><td class="name">oDT</td><td class="type type-param">object</td><td class="attributes"></td><td class="default"></td><td class="description last">DataTables settings object</td></tr><tr class="odd"><td class="number right_border"><div>2</div></td><td class="name">oOpts</td><td class="type type-param">object</td><td class="attributes">Optional</td><td class="default">{}</td><td class="description last">Configuration object for FixedColumns. Options are defined by Scroller.oDefaults</td></tr>
	</tbody>
</table><h5>Example:</h5>
    <div class="example-code">
    	<pre class="brush: js">		$(document).ready(function() {
			$('#example').dataTable( {
				"sScrollY": "200px",
				"sAjaxSource": "media/dataset/large.txt",
				"sDom": "frtiS",
				"bDeferRender": true
			} );
		} );</pre>
    </div>
</dl><h3 class="subsection-title">Requires</h3>
<ul>
	<li>jQuery 1.4+</li><li>DataTables 1.8.0+</li>
</ul>
					</div>

					<div class="doc_summary">
						<a name="summary"></a>
						<h2>Summary</h2>

						<div class="doc_group"><a name="summary_namespaces"></a><h3 class="subsection-title">Namespaces</h3>
<dl>
	<dt class="even"><span class="type-name"><a href="_anonymous__Scroller_dom.html">dom</a></span></dt><dd class="even">DOM elements used by the class instance</dd><dt class="odd"><span class="type-name"><a href="_anonymous__Scroller.oDefaults.html">oDefaults</a></span></dt><dd class="odd">Scroller default settings for initialisation</dd><dt class="even"><span class="type-name"><a href="_anonymous__Scroller_s.html">s</a></span></dt><dd class="even">Settings object which contains customisable information for the Scroller instance</dd>
</dl></div><div class="doc_group"><a name="summary_methods"></a><h3 class="subsection-title">Methods</h3>

<dl>
    <dt class=" even"><span class="type-attr"></span><span class="type-name"><a href="#fnPixelsToRow_details">fnPixelsToRow</a></span><span class="type-sig"><span class="type-brace">(</span> iPixels:<span class="type-param">int</span> <span class="type-brace">)</span>:<span class="type-return">int</span></span></dt><dd class=" even">Calculate the row number that will be found at the given pixel position (y-scroll)</dd><dt class=" odd"><span class="type-attr"></span><span class="type-name"><a href="#fnRowToPixels_details">fnRowToPixels</a></span><span class="type-sig"><span class="type-brace">(</span> iRow:<span class="type-param">int</span> <span class="type-brace">)</span>:<span class="type-return">int</span></span></dt><dd class=" odd">Calculate the pixel position from the top of the scrolling container for a given row</dd><dt class=" even"><span class="type-attr"></span><span class="type-name"><a href="#fnScrollToRow_details">fnScrollToRow</a></span><span class="type-sig"><span class="type-brace">(</span> iRow:<span class="type-param">int</span>, [bAnimate:<span class="type-param">bool</span>] <span class="type-brace">)</span>:<span class="type-return">void</span></span></dt><dd class=" even">Calculate the row number that will be found at the given pixel position (y-scroll)</dd><dt class="private odd"><span class="type-attr">&lt;private> </span><span class="type-name"><a href="#_fnCalcRowHeight_details">_fnCalcRowHeight</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></dt><dd class="private odd">Automatic calculation of table row height. This is just a little tricky here as using
initialisation DataTables has tale the table out of the document, so we need to create
a new table and insert it into the document, calculate the row height and then whip the
table out.</dd><dt class="private even"><span class="type-attr">&lt;private> </span><span class="type-name"><a href="#_fnConstruct_details">_fnConstruct</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></dt><dd class="private even">Initialisation for Scroller</dd><dt class="private odd"><span class="type-attr">&lt;private> </span><span class="type-name"><a href="#_fnDrawCallback_details">_fnDrawCallback</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></dt><dd class="private odd">Draw callback function which is fired when the DataTable is redrawn. The main function of
this method is to position the drawn table correctly the scrolling container for the rows
that is displays as a result of the scrolling position.</dd><dt class="private even"><span class="type-attr">&lt;private> </span><span class="type-name"><a href="#_fnInfo_details">_fnInfo</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></dt><dd class="private even">Update any information elements that are controlled by the DataTable based on the scrolling
viewport and what rows are visible in it. This function basically acts in the same way as
_fnUpdateInfo in DataTables, and effectively replaces that function.</dd><dt class="private odd"><span class="type-attr">&lt;private> </span><span class="type-name"><a href="#_fnScroll_details">_fnScroll</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></dt><dd class="private odd">Scrolling function - fired whenever the scrolling position is changed. This method needs
to use the stored values to see if the table should be redrawn as we are moving towards
the end of the information that is currently drawn or not. If needed, then it will redraw
the table based on the new position.</dd>
</dl></div>
					</div>


					<div class="doc_details">
						<a name="details"></a>
						<h2>Details</h2>
						<div class="doc_group"><a name="details_methods"></a><h3 class="subsection-title">Methods</h3>
<dl>
    <dt id="<anonymous>~Scroller#fnPixelsToRow" class=" even"><a name="fnPixelsToRow_details"></a><span class="type-attr"></span><span class="type-name"><a>fnPixelsToRow</a></span><span class="type-sig"><span class="type-brace">(</span> iPixels:<span class="type-param">int</span> <span class="type-brace">)</span>:<span class="type-return">int</span></span></span></dt><dd class=" even"><p class="description">Calculate the row number that will be found at the given pixel position (y-scroll)</p><dl class="details">
	
	
	
	
	
	
	
	
	
	
	
	
	
</dl><h5>Parameters:</h5>

<table class="params">
    <thead>
	<tr>
        <th width="20"></th>
        <th width="12%" class="bottom_border name">Name</th>
		<th width="10%" class="bottom_border">Type</th>
		<th width="10%" class="bottom_border">Attributes</th>
		<th width="10%" class="bottom_border">Default</th>
		<th class="last bottom_border">Description</th>
	</tr>
	</thead>
	
	<tbody>
	<tr class="even"><td class="number right_border"><div>1</div></td><td class="name">iPixels</td><td class="type type-param">int</td><td class="attributes"></td><td class="default"></td><td class="description last">Offset from top to caluclate the row number of</td></tr>
	</tbody>
</table><h5>Returns:</h5><p class="returns">Row index</p><h5>Example:</h5>
    <div class="example-code">
    	<pre class="brush: js"> 	$(document).ready(function() {
 		$('#example').dataTable( {
 			"sScrollY": "200px",
 			"sAjaxSource": "media/dataset/large.txt",
 			"sDom": "frtiS",
 			"bDeferRender": true,
 			"fnInitComplete": function () {
 				// Find what row number is at 500px
 				alert( this.oScroller.fnPixelsToRow( 500 ) );
 			}
 		} );
 	} );</pre>
    </div>
<dt id="<anonymous>~Scroller#fnRowToPixels" class=" odd"><a name="fnRowToPixels_details"></a><span class="type-attr"></span><span class="type-name"><a>fnRowToPixels</a></span><span class="type-sig"><span class="type-brace">(</span> iRow:<span class="type-param">int</span> <span class="type-brace">)</span>:<span class="type-return">int</span></span></span></dt><dd class=" odd"><p class="description">Calculate the pixel position from the top of the scrolling container for a given row</p><dl class="details">
	
	
	
	
	
	
	
	
	
	
	
	
	
</dl><h5>Parameters:</h5>

<table class="params">
    <thead>
	<tr>
        <th width="20"></th>
        <th width="12%" class="bottom_border name">Name</th>
		<th width="10%" class="bottom_border">Type</th>
		<th width="10%" class="bottom_border">Attributes</th>
		<th width="10%" class="bottom_border">Default</th>
		<th class="last bottom_border">Description</th>
	</tr>
	</thead>
	
	<tbody>
	<tr class="even"><td class="number right_border"><div>1</div></td><td class="name">iRow</td><td class="type type-param">int</td><td class="attributes"></td><td class="default"></td><td class="description last">Row number to calculate the position of</td></tr>
	</tbody>
</table><h5>Returns:</h5><p class="returns">Pixels</p><h5>Example:</h5>
    <div class="example-code">
    	<pre class="brush: js"> 	$(document).ready(function() {
 		$('#example').dataTable( {
 			"sScrollY": "200px",
 			"sAjaxSource": "media/dataset/large.txt",
 			"sDom": "frtiS",
 			"bDeferRender": true,
 			"fnInitComplete": function () {
 				// Find where row 25 is
 				alert( this.oScroller.fnRowToPixels( 25 ) );
 			}
 		} );
 	} );</pre>
    </div>
<dt id="<anonymous>~Scroller#fnScrollToRow" class=" even"><a name="fnScrollToRow_details"></a><span class="type-attr"></span><span class="type-name"><a>fnScrollToRow</a></span><span class="type-sig"><span class="type-brace">(</span> iRow:<span class="type-param">int</span>, [bAnimate:<span class="type-param">bool</span>] <span class="type-brace">)</span>:<span class="type-return">void</span></span></span></dt><dd class=" even"><p class="description">Calculate the row number that will be found at the given pixel position (y-scroll)</p><dl class="details">
	
	
	
	
	
	
	
	
	
	
	
	
	
</dl><h5>Parameters:</h5>

<table class="params">
    <thead>
	<tr>
        <th width="20"></th>
        <th width="12%" class="bottom_border name">Name</th>
		<th width="10%" class="bottom_border">Type</th>
		<th width="10%" class="bottom_border">Attributes</th>
		<th width="10%" class="bottom_border">Default</th>
		<th class="last bottom_border">Description</th>
	</tr>
	</thead>
	
	<tbody>
	<tr class="even"><td class="number right_border"><div>1</div></td><td class="name">iRow</td><td class="type type-param">int</td><td class="attributes"></td><td class="default"></td><td class="description last">Row index to scroll to</td></tr><tr class="odd"><td class="number right_border"><div>2</div></td><td class="name">bAnimate</td><td class="type type-param">bool</td><td class="attributes">Optional</td><td class="default">true</td><td class="description last">Animate the transision or not</td></tr>
	</tbody>
</table><h5>Example:</h5>
    <div class="example-code">
    	<pre class="brush: js"> 	$(document).ready(function() {
 		$('#example').dataTable( {
 			"sScrollY": "200px",
 			"sAjaxSource": "media/dataset/large.txt",
 			"sDom": "frtiS",
 			"bDeferRender": true,
 			"fnInitComplete": function () {
 				// Immediately scroll to row 1000
 				this.oScroller.fnScrollToRow( 1000 );
 			}
 		} );
 	} );</pre>
    </div>
<dt id="<anonymous>~Scroller#_fnCalcRowHeight" class="private odd"><a name="_fnCalcRowHeight_details"></a><span class="type-attr">&lt;private> </span><span class="type-name"><a>_fnCalcRowHeight</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></span></dt><dd class="private odd"><p class="description">Automatic calculation of table row height. This is just a little tricky here as using
initialisation DataTables has tale the table out of the document, so we need to create
a new table and insert it into the document, calculate the row height and then whip the
table out.</p><dl class="details">
	
	
	
	
	
	
	
	
	
	
	
	
	
</dl><dt id="<anonymous>~Scroller#_fnConstruct" class="private even"><a name="_fnConstruct_details"></a><span class="type-attr">&lt;private> </span><span class="type-name"><a>_fnConstruct</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></span></dt><dd class="private even"><p class="description">Initialisation for Scroller</p><dl class="details">
	
	
	
	
	
	
	
	
	
	
	
	
	
</dl><dt id="<anonymous>~Scroller#_fnDrawCallback" class="private odd"><a name="_fnDrawCallback_details"></a><span class="type-attr">&lt;private> </span><span class="type-name"><a>_fnDrawCallback</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></span></dt><dd class="private odd"><p class="description">Draw callback function which is fired when the DataTable is redrawn. The main function of
this method is to position the drawn table correctly the scrolling container for the rows
that is displays as a result of the scrolling position.</p><dl class="details">
	
	
	
	
	
	
	
	
	
	
	
	
	
</dl><dt id="<anonymous>~Scroller#_fnInfo" class="private even"><a name="_fnInfo_details"></a><span class="type-attr">&lt;private> </span><span class="type-name"><a>_fnInfo</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></span></dt><dd class="private even"><p class="description">Update any information elements that are controlled by the DataTable based on the scrolling
viewport and what rows are visible in it. This function basically acts in the same way as
_fnUpdateInfo in DataTables, and effectively replaces that function.</p><dl class="details">
	
	
	
	
	
	
	
	
	
	
	
	
	
</dl><dt id="<anonymous>~Scroller#_fnScroll" class="private odd"><a name="_fnScroll_details"></a><span class="type-attr">&lt;private> </span><span class="type-name"><a>_fnScroll</a></span><span class="type-sig"><span class="type-brace">(</span>  <span class="type-brace">)</span>:<span class="type-return">void</span></span></span></dt><dd class="private odd"><p class="description">Scrolling function - fired whenever the scrolling position is changed. This method needs
to use the stored values to see if the table should be redrawn as we are moving towards
the end of the information that is currently drawn or not. If needed, then it will redraw
the table based on the new position.</p><dl class="details">
	
	
	
	
	
	
	
	
	
	
	
	
	
</dl>
</dd></div>
   				</div>
   			</div>
			
		</div>

		<div class="fw_footer">
			Scroller: Copyright 2011 Allan Jardine, all rights reserved<br>

			Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
			26th Jun 2011 - 09:41
			with the <a href="http://datatables.net/">DataTables</a> template.
		</div>
	</body>
</html>